{extend name="public/help" /}
{block name="oneMenuName"}{$data['oneMenuName']}{/block}
{block name="twoMenuName"}{$data['twoMenuName']}{/block}
{block name="body"}
<div class="main-content">
    <div class="row">
        <div class="col-lg-6">
            <a href="{:url('/admin/addBusines')}">
                <button type="button" class="btn btn-primary btn-flat btn-addon m-b-10 m-l-5"><i class="ti-plus"></i>添加商家
                </button>
            </a>
            <div class="card alert">
                <div class="card-header">
                    <h4>搜索</h4>
                </div>
                <div class="card-body">
                    <div class="basic-form">
                        <form>
                            <div class="form-group">
                                <!--                                <p class="text-muted m-b-15 f-s-12">Use the input classes on an <code>input-default</code> for Default input.</p>-->
                                <div class="input-group input-group-default">
                                    <span class="input-group-btn">
                                        <button class="btn btn-primary" type="submit">
                                            <i class="ti-search"></i>
                                        </button>
                                    </span>
                                    <input type="text" placeholder="Search Default" value="{$Request.get.search}" name="search" class="form-control">
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
                <div class="card alert">
                    <div class="card-header">
                        <h4>用户列表</h4>
                    </div>
                    <div class="card-body">
                        <table class="table table-responsive table-bordered">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>商家名称</th>
                                <th>商家联系人</th>
                                <th>商家电话</th>
                                <th>商家地址</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {foreach $lists as $k => $v}
                            <tr>
                                <td scope="row">{$v.id}</td>
                                <td scope="row">{$v.name}</td>
                                <td scope="row">{$v.user_name}</td>
                                <td scope="row">{$v.phone}</td>
                                <td scope="row">{$v.addr}</td>
                                <td >
                                    <a href="">
                                        <button type="button" class="btn btn-info m-b-10 m-l-3">详情</button>
                                    </a>
                                    <a href="{:url('/admin/editbusines', ['id' => $v.id])}"><button type="button" class="btn btn-warning m-b-10 m-l-5">修改</button></a>
                                    {eq name="1" value="$v.status"}
                                    <a href="javascript:;" class="del" ids="{$v.id}"><button type="button" class="btn btn-danger m-b-10 m-l-5">关闭商家</button></a>
                                    {/eq}
                                </td>
                            </tr>
                            {/foreach}
                            </tbody>
                        </table>
                        {$lists->render()}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

{/block}
{block name="js"}
<script>
    $('.del').click(function () {
        var id = $(this).attr('ids');
        if(!id) {error('参数有误');return;}

        layer.confirm('确定关闭吗？', {btn: ['关闭','取消']}, function(){
            var url = "{:url('/admin/closeBusines')}";
            var datas = {
                id : id
            };

            $.ajax({
                type : 'post',
                url : url,
                data : datas,
                success : function(res){
                    if(res.code){
                        reload_success(res.msg);
                    }else{
                        error(res.msg);
                    }
                }
            });
        });
    });
</script>
{/block}

